package org.cook.utils.html.yyyy;

import org.cook.utils.common.Constants;
import org.cook.utils.common.Utils;

public class Doctor implements Comparable<Doctor> {
	private int id;
	
	private String name;
	private String pinyinName;
	private String title;
	private String dept;
	private String worktime;
	private String skillDesc;
	private String fileName;
	
	public Doctor() { }

	public Doctor(String name, String worktime, String skillDesc) {
		this();
		String[] ss = name.split("\u3000+");
		setName(ss[0]);
		setPinyinName(Utils.stringToPinyin(getName()));
		
		if (ss.length == 2) setTitle(ss[1]);
		
		setWorktime(worktime);
		if (worktime.indexOf('隔') > 0) setName(getName() + "*");
		setSkillDesc(skillDesc);
	}
	
	public Doctor(String name, String dept) {
		this();
		setName(name);
		setDept(dept);
	}

	public String toHtml() {
		StringBuilder html = new StringBuilder();
		
		html.append("<tr style='font-weight: bold;font-size: 12px;").append(id % 2 == 0 ? "" : "color: green;").append("'>").append(Constants.NEW_LINE_UNIX);
		html.append("   ").append("<td rowspan='2'>").append(getId()).append("</td>").append(Constants.NEW_LINE_UNIX);
		html.append("   ").append("<td width='7%'>主治医生: </td><td>").append(getName()).append("</td>").append(Constants.NEW_LINE_UNIX);
		html.append("   ").append("<td>出诊时间: </td><td>").append(getWorktime()).append("</td>").append(Constants.NEW_LINE_UNIX);
		html.append("</tr>").append(Constants.NEW_LINE_UNIX);
		
		html.append("<tr style='font-size: 12px;").append(id % 2 == 0 ? "" : "color: green;").append("'>").append(Constants.NEW_LINE_UNIX);
		html.append("   ").append("<td width='7%'>专业擅长: </td><td colspan='3'>").append(getSkillDesc()).append("</td>").append(Constants.NEW_LINE_UNIX);
		html.append("</tr>").append(Constants.NEW_LINE_UNIX);
		
		return html.toString();
	}
	
	public String toText() {
		StringBuilder text = new StringBuilder();
		
		text.append(getId()).append("  ").append("主治医生").append(": ").append(getName());
		text.append("    ").append("出诊时间").append(": ").append(getWorktime()).append("   ").append(getFileName()).append(Constants.NEW_LINE_UNIX);
		text.append("专业擅长").append(": ").append(getSkillDesc()).append(Constants.NEW_LINE_UNIX);
		
		return text.toString();
	}
	
	/*
	 *      11  12  13   14  15  16  17
	 * 上午: 周一 周二 周三 周四 周五 周六 周日
	 *      21  22  23   24  25  26  27
	 * 下午: 周一 周二 周三 周四 周五 周六 周日
	 * 
	 */
	public int getWorkTimeDay() {// 周四下午
		
		int time = worktime.indexOf('下') > 0 ? 20 : 10;
		
		if (worktime.indexOf('一') > 0) {
			time = time + 1;
		} else if (worktime.indexOf('二') > 0) {
			time = time + 2;
		} else if (worktime.indexOf('三') > 0) {
			time = time + 3;
		} else if (worktime.indexOf('四') > 0) {
			time = time + 4;
		} else if (worktime.indexOf('五') > 0) {
			time = time + 5;
		} else if (worktime.indexOf('六') > 0) {
			time = time + 6;
		} else if (worktime.indexOf('日') > 0) {
			time = time + 7;
		} 
		
		return time;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPinyinName() {
		return pinyinName;
	}
	public void setPinyinName(String pinyinName) {
		this.pinyinName = pinyinName;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDept() {
		return dept;
	}
	public void setDept(String dept) {
		this.dept = dept;
	}
	public String getWorktime() {
		return worktime;
	}
	public void setWorktime(String worktime) {
		this.worktime = worktime;
	}
	public String getSkillDesc() {
		return skillDesc;
	}
	public void setSkillDesc(String skillDesc) {
		this.skillDesc = skillDesc;
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public int compareTo(Doctor o) {
		return getPinyinName().compareTo(getPinyinName());
	}
	
}
